/*
* @(#)ListDmsAuditTrailForm.java
*
* Copyright (c) 2003 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.dms.web;

import java.util.Calendar;

import com.dcivision.framework.GlobalConstant;
import com.dcivision.framework.SystemParameterConstant;
import com.dcivision.framework.SystemParameterFactory;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.Utility;
import com.dcivision.framework.web.AbstractSearchForm;

/**
  ListDmsAuditTrailForm.java

  The ActionForm for ListDmsAuditTrailForm

    @author          Zoe Shum
    @company         DCIVision Limited
    @creation 18   01/09/2003
    @version         $Revision: 1.12.4.4 $
    */
public class ListDmsAuditTrailForm extends AbstractSearchForm {

  public static final String REVISION = "$Revision: 1.12.4.4 $";

  /** Holds value of property updateDateFrom.  */
  private String accessDateFrom;

  /** Holds value of property updateDateTo.  */
  private String accessDateTo;

  /** Holds value of property periodType.   */
  private String periodType = "month";

  /** Holds value of property accessType. */
  private String accessType;

  /** Holds value of property objectType. */
  private String objectType = GlobalConstant.OBJECT_TYPE_DOCUMENT;

  /** Holds value of property accessType. */
  private String objectID;

  /** Holds value of property curFunctionCode. */
  private String curFunctionCode;

  private String userRecordID;

  /** used for return button to get return navigation */
  private String directURL;

  private String objectName;

  private String lastPageNO;
  private String curPageNO;
  private String pageAmount;
  private String cursor;

  /*
   * Update Code Start
   * Author			Jim.Zhou
   * Date			2006/05/08
   * Bug			#3649
   */
  private String rootID;
  private String parentID;

	public String getParentID() {
		return parentID;
	}
	public void setParentID(String parentID) {
		this.parentID = parentID;
	}
	public String getRootID() {
		return rootID;
	}
	public void setRootID(String rootID) {
		this.rootID = rootID;
	}
	/*
	 * Update Code End
	 */

  public String getCurPageNO() {
		return curPageNO;
	}


	public void setCurPageNO(String curPageNO) {
		this.curPageNO = curPageNO;
	}

	public String getObjectName() {
	  return objectName;
  }


  public void setObjectName(String objectName) {
	  this.objectName = objectName;
  }


  public ListDmsAuditTrailForm() {
    super();
    this.setSortAttribute("ACCESS_DATE");
    this.setSortOrder("DESC");
    //define searchable attributes for filtering box display
    this.addSearchableAttribute("accessDateFrom");
    this.addSearchableAttribute("accessDateTo");
    this.addSearchableAttribute("periodType");
    this.addSearchableAttribute("accessType");
    this.addSearchableAttribute("objectType");
    this.addSearchableAttribute("objectID");
    this.addSearchableAttribute("userRecordID");
  }


  /** Getter for property updateDateFrom.
   * @return Value of property updateDateFrom.
   */
  public String getAccessDateFrom() {
    Calendar cal = Calendar.getInstance();
    if(Utility.isEmpty(periodType)){
      return accessDateFrom;
    }else if("week".equals(periodType)){
      cal.add(Calendar.DATE,1-cal.get(Calendar.DAY_OF_WEEK));
    }else if("month".equals(periodType)){
      cal.set(Calendar.DATE,1);
    }else if("full".equals(periodType)){
      return accessDateFrom; //EIP-2728
    }
    cal.set(Calendar.AM_PM, Calendar.AM);
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return TextUtility.formatDate(cal.getTime(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT));
  }

  /** Setter for property updateDateFrom.
   * @param updateDateFrom New value of property updateDateFrom.
   */
  public void setAccessDateFrom(String accessDateFrom) {
    this.accessDateFrom = accessDateFrom;
  }

  /** Getter for property updateDateTo.
   * @return Value of property updateDateTo.
   */
  public String getAccessDateTo() {
    Calendar cal = Calendar.getInstance();
    if(Utility.isEmpty(periodType)){
      return accessDateTo;
    }else if("week".equals(periodType)){
      cal.add(Calendar.DATE,7-cal.get(Calendar.DAY_OF_WEEK));
    }else if("month".equals(periodType)){
      cal.add(Calendar.MONTH,1);
      cal.set(Calendar.DATE,0);
    }else if("full".equals(periodType)){
      return accessDateTo; //EIP-2728
    }
    cal.set(Calendar.AM_PM, Calendar.PM);
    cal.set(Calendar.HOUR, 11);
    cal.set(Calendar.MINUTE, 59);
    cal.set(Calendar.SECOND, 59);
    cal.set(Calendar.MILLISECOND, 59);
    return TextUtility.formatDate(cal.getTime(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT));
  }

  /** Setter for property updateDateTo.
   * @param updateDateTo New value of property updateDateTo.
   */
  public void setAccessDateTo(String accessDateTo) {
    this.accessDateTo = accessDateTo;
  }

  /** Getter for property periodType.
   * @return Value of property periodType.
   */
  public String getPeriodType() {
    return this.periodType;
  }

  /** Setter for property periodType.
   * @param periodType New value of property periodType.
   */
  public void setPeriodType(String periodType){
    this.periodType = periodType;
  }

  /** Getter for property accessType.
   * @return Value of property accessType.
   */
  public String getAccessType() {
    return this.accessType;
  }

  /** Setter for property accessType.
   * @param accessType New value of property accessType.
   */
  public void setAccessType(String accessType) {
    this.accessType = accessType;
  }

  /** Getter for property objectType.
   * @return Value of property objectType.
   */
  public String getObjectType() {
    return(this.objectType);
  }

  /** Setter for property objectType.
   * @param objectType New value of property objectType.
   */
  public void setObjectType(String objectType) {
    this.objectType = objectType;
  }

  /** Getter for property objectID.
   * @return Value of property objectID.
   */
  public String getObjectID() {
    return(this.objectID);
  }

  /** Setter for property objectID.
   * @param objectID New value of property objectID.
   */
  public void setObjectID(String objectID) {
    this.objectID = objectID;
  }

  /** Getter for property curFunctionCode.
   * @return Value of property curFunctionCode.
   */
  public String getCurFunctionCode() {
    return(this.curFunctionCode);
  }

  /** Setter for property curFunctionCode.
   * @param curFunctionCode New value of property curFunctionCode.
   */
  public void setCurFunctionCode(String curFunctionCode) {
    this.curFunctionCode = curFunctionCode;
  }

  public String getUserRecordID(){
    return(this.userRecordID);
  }

  public void setUserRecordID(String userRecordID){
    this.userRecordID=userRecordID;
  }

  public String getDirectURL(){
    return this.directURL;
  }

  public void setDirectURL(String directURL){
    this.directURL=directURL;
  }


	public String getLastPageNO() {
		return lastPageNO;
	}


	public void setLastPageNO(String lastPageNO) {
		this.lastPageNO = lastPageNO;
	}


	public String getCursor() {
		return cursor;
	}


	public void setCursor(String cursor) {
		this.cursor = cursor;
	}


	public String getPageAmount() {
		return pageAmount;
	}


	public void setPageAmount(String pageAmount) {
		this.pageAmount = pageAmount;
	}


}
